<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../../commons/taglibs.jsp"%>
<%@ include file="../../commons/list.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta charset="utf-8">
  <title>修改密码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <style type="text/css">
  	input{
  		width: 150px;
  		display: inline;
  	}
  </style>
</head>

<body>
 <div>
	<div style="padding-top: 50px;">
		<form class="layui-form layui-form-pane"  action="">
		<input type="hidden" id='entityId' name='entityId' value="${sysUser.id }">
		 
		  <div class="layui-form-item" style="width: 85%;padding-left: 60px">
		    <label class="layui-form-label">原密码</label>
		     <div class="layui-input-block">
		      <input type="password" name="passwordOrd" name='passwordOrd' required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 60px">
		     <label class="layui-form-label">新密码</label>
		    <div class="layui-input-block">
		      <input type="password" id='passwordNew' name='passwordNew' required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		   <div class="layui-form-item" style="width: 85%;padding-left: 60px">
		     <label class="layui-form-label">确认密码</label>
		    <div class="layui-input-block">
		      <input type="password" id='passwordNewCon' name='passwordNewCon' onblur="confirm()" required  lay-verify="required" placeholder="请输入确认密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 80px;padding-top: 30px">
		    <div class="layui-input-block">
		      <button class="layui-btn" id='tjsub' lay-submit lay-filter="formDemo">立即提交</button>
		      <a class="layui-btn" onclick="closeWindow()"><i class="layui-icon">&#xe65c;</i>返回</a>
		    </div>
		  </div>
		</form>
	</div>
 </div> 

<script>

  layui.use(['layer','form','jquery'],function(){
    $ = layui.jquery;	
    var form = layui.form
   //监听提交
  form.on('submit(formDemo)', function(data){
	  var passwordNew = data.field.passwordNew;
	  var passwordNewCon = data.field.passwordNewCon;
	  if(passwordNew != passwordNewCon){
		  layer.open({
			  title: '信息'
			  ,content: '新密码和确认密码不一致'
		  }); 
		  return false;
	  }
	  
	  //提交成功后禁用按钮
	  $("#tjsub").css("pointer-events","none"); 
	  $.post('<%=basePath%>controller/sysUser/updatePwd',data.field,function(data){
		  if(data == '1'){
			  $("#tjsub").css("pointer-events","auto");
			  layer.msg('提交失败', {time:1000});
		  }
		  if(data == '0'){
			  layer.msg('提交成功，三秒后将进入登录界面', {time:3000});
			  //调用刷新页面
			  setTimeout("loginOut()",3000);
		  }
		  if(data == '2'){
			  $("#tjsub").css("pointer-events","auto");
			  layer.msg('旧密码不正确', {time:2000});
		  }
	  })
      return false;
  });
     
		
 });
  
  function confirm(){
	  debugger;
	  var passwordNew = $("#passwordNew").val();
	  var passwordNewCon = $("#passwordNewCon").val();
	  if(passwordNew != passwordNewCon){
		  layer.open({
			  title: '信息'
			  ,content: '新密码和确认密码不一致'
		  });    
	  }
  }
  
  function loginOut(){
	  parent.window.toLogin();
  }
//返回按钮事件
  function closeWindow(){
        var index = parent.layer.getFrameIndex(window.name);
  		parent.layer.close(index);
  } 
</script>
</body>
</html>
